#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDockWidget>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QDockWidget* dockWidget = new QDockWidget();
    this->addDockWidget(Qt::LeftDockWidgetArea,dockWidget);

    dockWidget->setWindowTitle("这是一个浮动窗口");

    QWidget* widget = new QWidget();
    dockWidget->setWidget(widget);

    QVBoxLayout* layout = new QVBoxLayout();
    widget->setLayout(layout);

    QPushButton* button = new QPushButton("按钮1");
    QLabel* label = new QLabel("这是一段文本");

    layout->addWidget(label);
    layout->addWidget(button);

    dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::TopDockWidgetArea);
}

MainWindow::~MainWindow()
{
    delete ui;
}

